const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sys_tenant', {
    id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "主键"
    },
    tenantId: {
      type: DataTypes.STRING(12),
      allowNull: true,
      defaultValue: "000000",
      comment: "租户ID",
      field: 'tenant_id'
    },
    tenantName: {
      type: DataTypes.STRING(50),
      allowNull: false,
      comment: "租户名称",
      field: 'tenant_name'
    },
    domain: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "域名地址"
    },
    backgroundUrl: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "系统背景",
      field: 'background_url'
    },
    linkman: {
      type: DataTypes.STRING(20),
      allowNull: true,
      comment: "联系人"
    },
    contactNumber: {
      type: DataTypes.STRING(20),
      allowNull: true,
      comment: "联系电话",
      field: 'contact_number'
    },
    address: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "联系地址"
    },
    accountNumber: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: -1,
      comment: "账号额度",
      field: 'account_number'
    },
    expireTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "过期时间",
      field: 'expire_time'
    },
    datasourceId: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "数据源ID",
      field: 'datasource_id'
    },
    licenseKey: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "授权码",
      field: 'license_key'
    },
    createUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建人",
      field: 'create_user'
    },
    createDept: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建部门",
      field: 'create_dept'
    },
    createTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "创建时间",
      field: 'create_time'
    },
    updateUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "修改人",
      field: 'update_user'
    },
    updateTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "修改时间",
      field: 'update_time'
    },
    status: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "状态"
    },
    isDeleted: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "是否已删除",
      field: 'is_deleted'
    }
  }, {
    sequelize,
    tableName: 'sys_tenant',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
